package com.example.mygame.controller;


import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;

import com.example.mygame.R;
import com.example.mygame.snake.common.Direction;
import com.example.mygame.snake.widget.GameView;


public class MainActivity4 extends AppCompatActivity implements View.OnClickListener{

    private GameView gameView;
    private ImageView imgGoLeft,imgGoUp,imgGoRight,imgGoDown;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main4);
        gameView = (GameView)findViewById(R.id.gameView);
        imgGoLeft = (ImageView)findViewById(R.id.imgDirLeft);
        imgGoUp = (ImageView)findViewById(R.id.imgDirUp);
        imgGoRight = (ImageView)findViewById(R.id.imgDirRight);
        imgGoDown = (ImageView)findViewById(R.id.imgDirDown);
        imgGoLeft.setOnClickListener(this);
        imgGoUp.setOnClickListener(this);
        imgGoRight.setOnClickListener(this);
        imgGoDown.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch(v.getId()){
            case R.id.imgDirLeft:
                gameView.goDirection(Direction.LEFT);
                break;
            case R.id.imgDirUp:
                gameView.goDirection(Direction.UP);
                break;
            case R.id.imgDirRight:
                gameView.goDirection(Direction.RIGHT);
                break;
            case R.id.imgDirDown:
                gameView.goDirection(Direction.DOWN);
                break;
        }
    }
}
